<template>
  <section class="section fade-in">
    <header class="head">
      <h3 class="title">{{ title }}</h3>
      <a v-if="more" class="more" :href="more">
        更多 <span class="arrow">→</span>
      </a>
    </header>
    <div class="grid">
      <VideoCard 
        v-for="(v, index) in items" 
        :key="v.id" 
        :video="v" 
        :index="index" 
      />
    </div>
  </section>
</template>

<script setup>
import VideoCard from './VideoCard.vue'

const props = defineProps({
  title: { type: String, required: true },
  items: { type: Array, default: () => [] },
  more: { type: String, default: '' }
})
</script>

<style scoped>
.section {
  margin-bottom: 40px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.section::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 4px;
  background: linear-gradient(to bottom, var(--accent), #8b5cf6);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.section:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--fg);
  position: relative;
  display: inline-block;
}

.title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -13px;
  width: 40px;
  height: 3px;
  background: var(--accent);
  border-radius: 3px;
}

.more {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  transition: all 0.3s ease;
  background: var(--accent-light);
}

.more:hover {
  background: var(--accent);
  color: white;
  transform: translateX(4px);
}

.arrow {
  transition: transform 0.3s ease;
}

.more:hover .arrow {
  transform: translateX(4px);
}

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* 响应式调整 */
@media (max-width: 768px) {
  .section {
    padding: 16px;
    margin-bottom: 32px;
  }
  
  .title {
    font-size: 18px;
  }
  
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: 1fr;
  }
  
  .head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .title::after {
    bottom: -25px;
  }
}
</style>